package org.dftproject.genesis.ui.pages.summary.details;

import org.dftproject.genesis.data.genealogy.IPerson;
import org.dftproject.genesis.data.genealogy.IRole;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.ToolbarLayout;

public class FamilyFigure extends Figure {
	
	private ChildrenFigure childrenFigure;
	
	public FamilyFigure(IPerson parent, IPerson spouse) {
		ToolbarLayout layout = new ToolbarLayout(false);
		layout.setStretchMinorAxis(true);
		setLayoutManager(layout);
		
		ParentFigure parentFigure = new ParentFigure(parent, spouse);
		layout = new ToolbarLayout(false);
		parentFigure.setLayoutManager(layout);
		parentFigure.setBorder(new MarginBorder(5));
		add(parentFigure);
	}

	public void addChild(IRole role) {
		if (childrenFigure == null) {
			childrenFigure = new ChildrenFigure();
			childrenFigure.setBorder(new MarginBorder(5));
			add(childrenFigure);
		}

		childrenFigure.addChild(role);
	}

}
